package com.example.demo.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.example.demo.custom.BaseRepository;
import com.example.demo.entity.CarNumberCompany1;
import com.example.demo.entity.CarNumberCompany2;

@Repository
public interface CarNumberCompanyRepository2 extends BaseRepository<CarNumberCompany2, Integer>{

	List<CarNumberCompany2> findByCarNumberCompany(CarNumberCompany1 carNum1);
	
	
	/**
	 * @param car
	 * @return 通过时间排序得到最新一条
	 */
	@Query(value = "SELECT  *  FROM car_number_company2 t WHERE t.car_number_company_id=? ORDER BY t.begin_date DESC LIMIT 1 ",nativeQuery=true)
	CarNumberCompany2 findByCarNumberCompany2(Integer carNum1);

}
